package view;


import java.awt.Frame;
import java.awt.Rectangle;
import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;

import javax.swing.JButton;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import components.ComponentUtil;

public class EinAuszahlenDialog extends JDialog{

	private static final long serialVersionUID = 1L;
	private JPanel jContentPane = null;
	private JLabel jLabel1 = null;
	private JLabel jLabel2 = null;
	private JLabel jLabel3 = null;
	private JLabel jLabel4 = null;

	private JTextField tfAlterKontostand = null;
	private JTextField tfKontostand = null;
	private JTextField tfBetrag = null;
	private JTextField tfNeuerKontostand = null;
	private JButton btKontostand = null;
	private JButton btEinzahlen = null;
	private JButton btAuszahlen = null;
	private JButton btEnde = null;
	/**
	 * @param owner
	 * @param b
	 */
	public EinAuszahlenDialog(Frame owner, boolean b) {
		super(owner);
		initialize();
		setVisible(b);
	}

	/**
	 * This method initializes this
	 *
	 * @return void
	 */
	private void initialize() {
		this.setSize(600, 500);
		this.setTitle("Bank-Anwendung - Ein-/Auszahlung durchführen");
		this.setContentPane(getJContentPane());
	}

	/**
	 * This method initializes jContentPane
	 *
	 * @return javax.swing.JPanel
	 */
	private JPanel getJContentPane() {
		if (jContentPane == null) {
			jLabel1 = new JLabel();
			jLabel1.setBounds(new Rectangle(31, 30, 122, 16));
			jLabel1.setText("Kontonummer");
			jLabel2 = new JLabel();
			jLabel2.setBounds(new Rectangle(31, 60, 120, 16));
			jLabel2.setText("alter Kontostand");
			jLabel3 = new JLabel();
			jLabel3.setBounds(new Rectangle(31, 90, 122, 16));
			jLabel3.setText("Betrag");
			jLabel4 = new JLabel();
			jLabel4.setBounds(new Rectangle(31, 120, 120, 16));
			jLabel4.setText("neuer Kontostand");
			jContentPane = new JPanel();
			jContentPane.setLayout(null);
			jContentPane.add(jLabel1, null);
			jContentPane.add(jLabel2, null);
			jContentPane.add(jLabel3, null);
			jContentPane.add(jLabel4, null);
			jContentPane.add(getTfAlterKontostand(), null);
			jContentPane.add(getTfKontonummer(), null);
			jContentPane.add(getTfBetrag(), null);
			jContentPane.add(getTfNeuerKontostand(), null);
			jContentPane.add(getBtKontostand(), null);
			jContentPane.add(getBtEinzahlung(), null);
			jContentPane.add(getBtAuszahlung(), null);
			jContentPane.add(getBtEnde(), null);
		}
		return jContentPane;
	}

	public JTextField getTfKontonummer() {
		if (tfKontostand == null) {
			tfKontostand = new JTextField();
			tfKontostand.setBounds(new Rectangle(165, 30, 165, 17));
			ComponentUtil.addEnterKeyDelegator(tfKontostand, getBtKontostand());
		}
		return tfKontostand;
	}

	public JTextField getTfAlterKontostand() {
		if (tfAlterKontostand == null) {
			tfAlterKontostand = new JTextField();
			tfAlterKontostand.setEditable(false);
			tfAlterKontostand.setBounds(new Rectangle(165, 60, 165, 17));
			tfAlterKontostand.addFocusListener(new FocusHandler());
		}
		return tfAlterKontostand;
	}

	public JTextField getTfBetrag() {
		if (tfBetrag == null) {
			tfBetrag = new JTextField();
			tfBetrag.setBounds(new Rectangle(165, 90, 165, 17));
		}
		return tfBetrag;
	}

	public JTextField getTfNeuerKontostand() {
		if (tfNeuerKontostand == null) {
			tfNeuerKontostand = new JTextField();
			tfNeuerKontostand.setEditable(false);
			tfNeuerKontostand.setBounds(new Rectangle(165, 120, 165, 17));
			tfNeuerKontostand.addFocusListener(new FocusHandler());
		}
		return tfNeuerKontostand;
	}

	/**
	 * This method initializes btAnlegen
	 *
	 * @return javax.swing.JButton
	 */
	public JButton getBtKontostand() {
		if (btKontostand == null) {
			btKontostand = new JButton();
			btKontostand.setBounds(new Rectangle(365, 30, 132, 33));
			btKontostand.setText("Kontostand");
			ComponentUtil.addDefaultButtonBehaviour(btKontostand);
		}
		return btKontostand;
	}

	public JButton getBtAuszahlung() {
		if (btAuszahlen == null) {
			btAuszahlen = new JButton();
			btAuszahlen.setBounds(new Rectangle(365, 90, 132, 33));
			btAuszahlen.setText("Auszahlen");
			ComponentUtil.addDefaultButtonBehaviour(btAuszahlen);
		}
		return btAuszahlen;
	}

	public JButton getBtEinzahlung() {
		if (btEinzahlen == null) {
			btEinzahlen = new JButton();
			btEinzahlen.setBounds(new Rectangle(365, 125, 132, 33));
			btEinzahlen.setText("Einzahlen");
			ComponentUtil.addDefaultButtonBehaviour(btEinzahlen);
		}
		return btEinzahlen;
	}

	public JButton getBtEnde() {
		if (btEnde == null) {
			btEnde = new JButton();
			btEnde.setBounds(new Rectangle(365, 185, 132, 32));
			btEnde.setText("Beenden");
			ComponentUtil.addDefaultButtonBehaviour(btEnde);
		}
		return btEnde;
	}


	// Inner Classes ***********************************************************

	private class FocusHandler implements FocusListener {
        @Override
        public void focusGained(FocusEvent e) {
            ((JComponent) e.getSource()).transferFocus();
        }

        @Override
        public void focusLost(FocusEvent e) {
        }
	}
}
